/*     */ package com.newcrm.webapi.sub;
/*     */ 
/*     */ import com.newcrm.bean.User;
/*     */ import com.newcrm.db.NoteManager;
/*     */ import com.newcrm.exception.DBException;
/*     */ import com.newcrm.util.Util;
/*     */ import com.newcrm.webapi.AbstractAction;
/*     */ import com.newcrm.webapi.AbstractHttpServlet;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintWriter;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import net.sf.json.JSONObject;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class UpdateNote extends AbstractAction
/*     */ {
/*  26 */   private int id = 0;
/*     */ 
/*  28 */   private static Logger logger = Logger.getLogger(UpdateNote.class.getName());
/*     */ 
/*     */   public UpdateNote(AbstractHttpServlet servlet) {
/*  31 */     super(servlet);
/*     */   }
/*     */ 
/*     */   public UpdateNote(AbstractHttpServlet servlet, String id) {
/*  35 */     super(servlet);
/*  36 */     this.id = Util.str2Int(id);
/*     */   }
/*     */ 
/*     */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*     */     throws IOException, ServletException
/*     */   {
/*  62 */     User loginUser = super.getLoginUser(request);
/*     */ 
/*  65 */     if (!loginUser.isAdmin)
/*     */     {
/*  67 */       super.showErrorMessage(response, "您没有修改该备注的权限");
/*  68 */       return;
/*     */     }
/*     */ 
/*  71 */     String userId = loginUser.userId;
/*  72 */     String updateType = request.getParameter("UpdateType");
/*  73 */     String attachFiles = request.getParameter("AttachFiles");
/*  74 */     String remark = request.getParameter("Remark");
/*  75 */     Date nextContactDate = Util.str2Date2(request
/*  76 */       .getParameter("NextContactDate"));
/*     */ 
/*  78 */     NoteManager manager = new NoteManager();
/*     */     try {
/*  80 */       int result = 0;
/*  81 */       if ("1".equals(updateType))
/*     */       {
/*  83 */         result = manager.updateCustomerNote(this.id, remark, 
/*  84 */           nextContactDate, attachFiles, userId);
/*  85 */       } else if ("3".equals(updateType))
/*     */       {
/*  87 */         result = manager.updateRemark(this.id, remark, userId);
/*     */       }
/*     */       else {
/*  90 */         result = manager.updateDealNote(this.id, remark, attachFiles, 
/*  91 */           userId);
/*     */       }
/*     */ 
/*  94 */       if (result > 0) {
/*  95 */         response.setContentType("text/html;charset=utf-8");
/*  96 */         PrintWriter out = response.getWriter();
/*  97 */         JSONObject jsonObject = new JSONObject();
/*  98 */         jsonObject.put("error", "0");
/*  99 */         jsonObject.put("result", Integer.valueOf(result));
/* 100 */         out.println(jsonObject);
/* 101 */         out.flush();
/* 102 */         out.close();
/* 103 */         return;
/*     */       }
/*     */     } catch (DBException e) {
/* 106 */       logger.warn("update note failed", e);
/*     */     } catch (SQLException e) {
/* 108 */       logger.warn("update note failed", e);
/*     */     }
/* 110 */     super.showErrorMessage(response, "修改备注失败，请稍后重试");
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.UpdateNote
 * JD-Core Version:    0.6.1
 */